package com.ybu;

import java.util.Comparator;
import java.util.TreeMap;


/**
 * @ProjectName: shixun
 * @Titile: TreeMapDemo
 * @Author: Jie
 * @Description: TODO
 */
public class TreeMapDemo {
    public static void main(String[] args) {
        test0();
    }
    private static void test1() {
        TreeMap<Student,String> treeMap = new TreeMap<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o2.getAge()-o1.getAge();
            }
        });
        treeMap.put(new Student("张三",18),"杭州");
        treeMap.put(new Student("李四",19),"上海");
        treeMap.put(new Student("王五",20),"北京");
        treeMap.put(new Student("赵六",21),"广州");
        treeMap.forEach((k,v)-> System.out.println(k+"-->"+v));
    }

    private static void test0() {
        TreeMap<Student,String> treeMap = new TreeMap<>();
        treeMap.put(new Student("张三",18),"杭州");
        treeMap.put(new Student("李四",19),"上海");
        treeMap.put(new Student("王五",20),"北京");
        treeMap.put(new Student("赵六",21),"广州");
        treeMap.forEach((k,v)-> System.out.println(k+"-->"+v));
    }
}
